package org.eenie.core.base

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

abstract class BaseFragment : Fragment() {

    lateinit var mRootView: View
    lateinit var mContext: Context

    override fun onCreate(savedInstanceState: Bundle?) {
        mContext = requireContext()
        initData(savedInstanceState)
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(getLayoutRes(), null)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mRootView = view
        initUI(view)
    }

    open fun initData(savedInstanceState: Bundle?) {

    }

    abstract fun getLayoutRes(): Int

    abstract fun initUI(mRootView: View)

}